﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GDF_kaart_inlezen;

namespace GDF_kaart_inlezen.strategy_classes
{
    class DataSetHeader : ReadingStrategy
    {
        public DataSetHeader()
        {
            recordCode = "02";
        }

        public override void Process(string record)
        {
            counter = 0;
            String fieldValue;

            if (record.Substring(0, 2) == recordCode) record = record.Substring(2);
            fieldValue = GetFieldValue("REC_CODE", ref record);
            String rec_code = fieldValue;
            if (rec_code == "01") //Data Set Indentification Subrecord
            {
                fieldValue = GetFieldValue("IDSI_NR", ref record);
                //ALWAYS BLANK, so no processing needed
                fieldValue = GetFieldValue("DASET_ID", ref record);
                //Implement processing
                fieldValue = GetFieldValue("ED_DATE", ref record);
                //Implement processing
                fieldValue = GetFieldValue("NUM_LAN", ref record);
                int num_lan = Int32.Parse(fieldValue);
                for (int i = 0; i < num_lan; i++)
                {
                    fieldValue = GetFieldValue("LAN_CODE", ref record);
                    //Implement processing
                }
                fieldValue = GetFieldValue("NUM_CNTRY", ref record);
                int num_cntry = Int32.Parse(fieldValue);
                for (int i = 0; i < num_cntry; i++)
                {
                    fieldValue = GetFieldValue("CNT_CODE", ref record);
                    //Implement processing
                }
            }
            else if (rec_code == "02") //Data Set Main Title Subrecord
            {
                fieldValue = GetFieldValue("LAN_CODE", ref record);
                //Implement processing
                fieldValue = record.Trim();
                //Implement processing (DASET_NAME)
            }
            else if (rec_code == "06") //Data Set Contents Subrecord
            {
                fieldValue = GetFieldValue("THEM_COD", ref record);
                //Implement processing
                fieldValue = record.Trim();
                //Implement processing (THEM_NAME)
            }
        }
    }
}
